#! /bin/bash
PROC_NAME=MediaServer
ProcNumber=`ps -ef |grep -w $PROC_NAME|grep -v grep|wc -l`

stop="stop"
if [ "$1"x == "$stop"x ];then
   echo "杀 ZLMediaKit 进程"
   if [ $ProcNumber -le 0 ];then
      echo "ZLMediaKit进程不存在，不需要杀进程"
   else
      ps -ef | grep MediaServer | grep -v grep | awk '{print $2}' | xargs kill -2
   fi
else

   if [ $ProcNumber -le 0 ];then
      echo "启动ZLMediaKit"
      ZLMediaKit/MediaServer -d &
   else
      echo "ZLMediaKit 已经在运行中,无需启动"
   fi
fi